package org.bird.jvm;

/**
 * @Described：演示JVM整个堆内存触发Full GC
 * @VM args : -XX:+UseConcMarkSweepGC -Xms20M -Xmx20M -Xmn10M -XX:SurvivorRatio=8 -XX:+PrintGCDetails
 * @author liangjf
 *
 */
public class FullGC {

	private static final int _1MB = 1024 * 1024;

	@SuppressWarnings("unused")
	public static void main(String[] args) throws InterruptedException {
		byte[] alloc1, alloc2, alloc3, alloc4;

		alloc1 = new byte[2 * _1MB];

		Thread.sleep(500);

		alloc2 = new byte[2 * _1MB];

		Thread.sleep(500);

		alloc3 = new byte[2 * _1MB];

		Thread.sleep(500);
		
		alloc3 = new byte[3 * _1MB];// 出现一次minor GC

		Thread.sleep(500);

		alloc4 = new byte[8 * _1MB];//出现一次full GC

		Thread.sleep(500);

	}
}
